<template>
<view class="cp_container">
	<view class="title">
		问题类型
	</view>
	<view class="chart_container">
		<qiun-data-charts
			type="column" 
			:chartData="chartData"
			:opts="opts"
			:disableScroll="true"
			@getIndex="chartClick"
			:ontouch="true"
			:canvas2d="true"
			canvasId="two_charts"/>
	</view>
</view>
</template>
<script>
	//问题状态图表
	import{
		doubleClick,
	} from "@/common/OtherTools";
	export default {
		data() {
			return {
				resData:{},
				chartData:{},
				opts:{
					"type": "column",
					"canvasId": "",
					"canvas2d": true,
					"background": "none",
					"animation": true,
					"timing": "easeOut",
					"duration": 1000,
					"color": [
						"#1890FF",
						"#91CB74",
						"#FAC858",
						"#EE6666",
						"#73C0DE",
						"#3CA272",
						"#FC8452",
						"#9A60B4",
						"#ea7ccc"
					],
					"padding": [
						15,
						15,
						15,
						15
					],
					"rotate": false,
					"errorReload": true,
					"fontSize": 10,
					"fontColor": "#666666",
					"enableScroll": true,
					"touchMoveLimit": 60,
					"enableMarkLine": false,
					"dataLabel": true,
					"dataPointShape": true,
					"dataPointShapeType": "solid",
					"xAxis": {
						"disabled": false,
						"axisLine": false,
						"axisLineColor": "#CCCCCC",
						"calibration": false,
						"fontColor": "#666666",
						"fontSize": 10,
						"rotateLabel": false,
						"itemCount": 4,
						"boundaryGap": "center",
						"disableGrid": true,
						"gridColor": "#CCCCCC",
						"gridType": "solid",
						"dashLength": 4,
						"gridEval": 1,
						"scrollShow": false,
						"scrollAlign": "left",
						"scrollColor": "#A6A6A6",
						"scrollBackgroundColor": "#EFEBEF",
						"format": "",
					},
					"yAxis": {
						"disabled": true,
						"disableGrid": true,
						"splitNumber": 5,
						"gridType": "solid",
						"dashLength": 8,
						"gridColor": "#CCCCCC",
						"padding": 10,
						"showTitle": false,
						"data": []
					},
					"legend": {
						"show": false,
						"position": "bottom",
						"float": "center",
						"padding": 5,
						"margin": 5,
						"backgroundColor": "rgba(0,0,0,0)",
						"borderColor": "rgba(0,0,0,0)",
						"borderWidth": 0,
						"fontSize": 13,
						"fontColor": "#666666",
						"lineHeight": 11,
						"hiddenColor": "#CECECE",
						"itemGap": 10
					},
					"extra": {
						"column": {
							"type": "stack",
							"width": 18,
							"seriesGap": 2,
							"categoryGap": 3,
							"barBorderCircle": false,
							"linearType": "none",
							"linearOpacity": 1,
							"colorStop": 0,
							"meterBorder": 1,
							"meterFillColor": "#FFFFFF",
							"activeBgColor": "#000000",
							"activeBgOpacity": 0.08,
							"meterBorde": 1
						},
						"tooltip": {
							"showBox": true,
							"showArrow": true,
							"showCategory": true,
							"borderWidth": 0,
							"borderRadius": 0,
							"borderColor": "#000000",
							"borderOpacity": 0.7,
							"bgColor": "#000000",
							"bgOpacity": 0.7,
							"gridType": "solid",
							"dashLength": 4,
							"gridColor": "#CCCCCC",
							"fontColor": "#FFFFFF",
							"splitLine": true,
							"horizentalLine": false,
							"xAxisLabel": false,
							"yAxisLabel": false,
							"labelBgColor": "#FFFFFF",
							"labelBgOpacity": 0.7,
							"labelFontColor": "#666666"
						},
						"markLine": {
							"type": "solid",
							"dashLength": 4,
							"data": []
						}
					}
				},
			};
		},
		mounted() {
			this.getData();
		},
		methods: {
			getData(){
				this.$ajax({ 
					url: '/sys/web/quest',
					method: 'POST',
					data:{
						query:'type',
					},
					success:res => {
						this.resData = res.data.data;
						this.drawChart(res.data.data);
					}
				});
			},
			drawChart(dataList){  //绘制图表
				this.chartData = {
					categories: dataList.map(item=>{
						return item.title;
					}),
					series:[
						{
							"name": " ",
							"data":dataList.map(item=>{
								return item.count;
							}),
							"color": '#1890FF',
							
						},
					],
				};
			},
			chartClick:doubleClick(function(param){
				param = this.resData[param.currentIndex.index].title;
				uni.setStorageSync('type', param);
				uni.switchTab({
				    url: `/pages/project_wt/project_wt`,
				});
			}),
		},
	}
</script>

<style lang="scss" scoped>
	.cp_container {
		width: 100%;
		height: 200px;
		background-color: #ffffff;
		box-sizing: border-box;
		.title{
			font-size: 12px;
			font-weight: bold;
			color: #555555;
			text-align: center;
			line-height: 2;
		}
		.chart_container {
			width: 100%;
			height: calc(100% - 24px);
			background-color: #FFFFFF;
		}
	}
</style>
